package servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class MyServlet2 extends HttpServlet {
    @Override
    public void init() throws ServletException {
        super.init();
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        ServletOutputStream out = resp.getOutputStream();
        out.write("姓名：顾建宇".getBytes(StandardCharsets.UTF_8));
        out.write("</br>".getBytes(StandardCharsets.UTF_8));
        out.write("学号：2023022026".getBytes(StandardCharsets.UTF_8));
        out.flush();
        out.close();
    }

    @Override
    public void destroy() {
        super.destroy();
    }
}
